home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ASME's Mechanical Engine…ing Toolkit 1997 December
/
ASME's Mechanical Engineering Toolkit 1997 December.iso
/
elec_eng
/
eepddsk2.lzh
/
TRAN_RES.BAS
< prev
next >
Wrap
BASIC Source File
|
1987-02-08
|
4KB
|
103 lines
10 REM FILE NAME IS TRANRES.BAS 9/27/83 ,ADDED BUILT IN IMPULSE,STEP,ETC G.H.
20 REM***DEFDBL A,B,E,T,F,X
30 CLS: PRINT : DEFINT J,I,N,K
40 PRINT TAB(20) "TRANSIENT ANALYSIS PROGRAM"
45 PRINT : PRINT "THIS PROGRAM IS A MODIFIED VERSION OF A PROGRAM THAT APPEARED"
46 PRINT : PRINT "IN FEB. 18,81 EDN, ""EASY-TO -USE BASIC PROGRAM ANALYZES TRANSIENT RESPONSE""
47 PRINT : PRINT "G.H. ADDED BUILT IN IMPULSE,STEP AND RAMP"
48 PRINT : PRINT "ARTICLE AND ORIGINAL VERSION OF PROGRAM WERE BY W.L. GILL"
50 PRINT : PRINT TAB(10) "COPYRIGHT DECEMBER 8, 1979 BY W.L. GILL" : PRINT
60 PRINT : PRINT "THE PROGRAM SOLVES THE TRANSIENT RESPONSE OF THE POLYNOMIAL"
70 PRINT:PRINT"EQUATION A(M)S^M+A(M-1)^S(M-1)...+A(0)/B(N)S^N+B(N-1)S^(N-1).
80 PRINT : PRINT "N MUST BE EQUAL TO OR GREATER THAN M. (S=(-1)[S*W)"
90 PRINT : PRINT "THE INPUT MUST BE A KNOWN FUNCTION OF TIME (T)"
100 PRINT:PRINT "IF INPUT IS NOT A IMPULSE,STEP OR RAMP,ENTER 4 BELOW AND"
110 PRINT:PRINT "RELACE LINE 940 WITH EI = FCN(T)."
120 PRINT:INPUT "ENTER 1 FOR IMPULSE RESPONSE,2 FOR STEP RESPONSE,3 FOR RAMP,4 FOR OTHER";P
130 IF P < 3 GOTO 150
140 PRINT:IF P=3 THEN INPUT "ENTER SLOPE OF RAMP, M = ";M
150 REM TRANSFER FUNCTION INPUT *********************************************
160 CLS
170 INPUT "ORDER OF DENOMINATOR " ; N
180 DIM X(1,N),A(N),B(N),EO(1000)
190 PRINT "INPUT COEFFICIENTS IN DECENDING ORDER IE. A4,A3,A2,A1,A0"
200 PRINT " NUMERATOR COEFFICIENTS"
210 FOR I = 0 TO N : PRINT "A(";N-I;") = " ; : INPUT A(I) : NEXT I
220 PRINT "DENOMINATOR COEFFICIENTS"
230 FOR I = 0 TO N : PRINT "B(";N-I;") = " ; : INPUT B(I) : NEXT I
240 REM TIME BASE INPUT *********************************************
250 INPUT "INPUT MAXIMUM TIME LIMIT" ; TF
260 INPUT "FAST OR ACCURATE SOLUTION (F/A) " ; A$
270 IF A$ = "A" OR A$="a" THEN K = 1000 ELSE K=100
280 TD = TF/K
290 REM STATE VARIABLE INTEGRATION LOOP ******************************
300 FOR J = 0 TO K : T = TD*J
310 FB = 0 : GOSUB 870
320 FOR I = 1 TO N : FB = FB+X(1,I)*B(I) : NEXT I
330 X(1,0) = (1/B(0))*(EI-FB)
340 FOR I = 1 TO N : X(1,I) = X(0,I)+.5*(X(1,I-1)+X(0,I-1))*TD
350 X(0,I-1) = X(1,I-1) : NEXT I
360 X(0,N) = X(1,N)
370 EO(J) = 0
380 FOR I = 0 TO N : EO(J) = EO(J)+A(I)*X(1,I) : NEXT I
390 IF EO(J) > MA THEN MA = EO(J) : TM = T
400 IF EO(J) < MI THEN MI = EO(J) : TI = T
410 NEXT J
420 REM DISPLAY SELECT **************************************************
430 INPUT "GRAPHIC PLOT (Y/N) " ; G$
440 IF G$ = "Y" OR G$="y" THEN 630
450 INPUT " DISPLAY ONLY THE MAXIMUM - MINIMUM (Y/N) " ; M$
460 IF M$ = "Y" THEN 780
470 Z = 1
480 PRINT "VALUE" , "TIME"
490 FOR I = 0 TO 100
500 IF K > 100 THEN J = I*10
510 IF K = 100 THEN J = I
520 T = TD*J : PRINT EO(J) , T
530 Z = Z + 1
540 IF Z = 15 THEN PRINT " PRESS ENTER TO CONTINUE" ; : INPUT Z$
550 IF Z = 15 THEN Z = 0
560 NEXT I
570 PRINT : PRINT "MAXIMUM = " ; MA , "TIME" ; TM
580 PRINT "MINIMUM =" ; MI , "TIME" ; TI
590 INPUT "DO YOU WISH A NEW PLOT (Y/N)" ; Y$
600 IF Y$ = "N" GOTO 850
610 MI = 0 : MA = 0 : TM = 0 : TI = 0 : FOR I=0 TO K : EO(I) = 0 : NEXT I
620 FOR I = 0 TO N : X(0,I) = 0 : X(1,I) = 0 : NEXT I : GOTO 240
630 REM VIDEO DISPLAY ROUTINE *********************************************
640 CLS:
650 FOR R = 1 TO 25
660 LOCATE R,1 :PRINT"."
670 IF (R-3)/10 = INT((R-3)/10) THEN LOCATE R,2:PRINT".":LOCATE R,3:PRINT"."
680 NEXT R
690 FOR C = 1 TO 80
700 LOCATE 11,C : PRINT"."
710 IF (C-11)/10=INT((C-11)/10) THEN LOCATE 12,C:PRINT".":LOCATE 10,C:PRINT"."
720 NEXT C
730 IF MA >= ABS(MI) THEN SY = MA
740 IF MA < ABS(MI) THEN SY = ABS(MI)
750 SM = -SY : PRINT ". MAX. =";SY
760 PRINT ". TRANSIENT RESPONSE TIME BASE" ; TF ; "SECONDS"
770 FOR I = 0 TO 79
780 IF K = 1000 THEN J = 10*I
790 IF K >< 1000 THEN J = I
800 C = I+1 : R = 11 - INT ((EO(J)*10/SY)+.5)
810 LOCATE R,C :PRINT"*"
820 NEXT I
830 LOCATE 24,10
840 PRINT, "DO YOU WISH A NEW PLOT (Y/N) " ; : INPUT Y$
850 IF Y$ = "Y" OR Y$="y" THEN CLS : GOTO 610
860 END
870 ON P GOTO 880,910,930,950
880 IF J < 1 THEN EI = 1/TD
890 IF J >= 1 THEN EI= 0
900 RETURN
910 EI = 1
920 RETURN
930 EI=M*T
940 RETURN
950 REM ENTER EI=FUNCTION OF TIME IN THIS SUBROUTINE **********************
960 EI = 1
970 :
980 RETURN